package com.ruitu.health_2.ui.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ruitu.arad.base.base_list.ListBaseAdapter;
import com.ruitu.arad.base.base_list.SuperViewHolder;
import com.ruitu.arad.util.ScreenUtils;
import com.ruitu.arad.util.SizeUtils;
import com.ruitu.health_2.R;
import com.ruitu.router_module.bean.product.Video;
import com.ruitu.router_module.util.GlideUtil;

// 模块下的视频列表adapter
public class ModelVideoListAdapter extends ListBaseAdapter<Video> {

    public ModelVideoListAdapter(Context context) {
        super(context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_model_video_list;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        ImageView icon = holder.getView(R.id.icon);
        TextView tv_name = holder.getView(R.id.tv_name);
        TextView tv_subname = holder.getView(R.id.tv_subname);

        int screenWidth = ScreenUtils.getScreenWidth();
        int picWidth = (screenWidth - SizeUtils.dp2px(30)) / 2;
        int picHeight = picWidth * 10 / 16;
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) icon.getLayoutParams();
        params.width = picWidth;
        params.height = picHeight;
        icon.setLayoutParams(params);

        Video v = mDataList.get(position);
        tv_name.setText(v.getTitle());
        tv_subname.setText(v.getDetail());

        GlideUtil.loadImg(v.getImgUrl(), icon);
    }
}
